package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Orders;
import com.foreknow.elmboot.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    //    /OrdersController/creatOrders
    @RequestMapping("/creatOrders")
    public int creatOrders(Orders orders) {

        return ordersService.creatOrders(orders);
    }

    //OrdersController/getOrdersById
    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId) {
        return ordersService.getOrdersById(orderId);
    }

    //OrdersController/listOrdersByUserId
    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(String userId) {
        return ordersService.listOrdersByUserId(userId);
    }
}
